<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../resources/js-test.js"></script>
</head>
<body>
<input id=target type=text value="">
<script>
description("An event's 'stop propagation', 'stop immediate propagation' and 'canceled' flags should be unset in initEvent");

window.jsTestIsAsync = true;

var e = document.createEvent("Event");
e.initEvent("foo", true, true);

e.preventDefault();
shouldBeTrue("e.defaultPrevented");
e.stopPropagation();
e.stopImmediatePropagation();

debug("Running e.initEvent again.");
e.initEvent("foo", true, true);
shouldBeFalse("e.defaultPrevented");

var target = document.getElementById("target");

target.addEventListener("foo", function (ev) {
    // This function will run if the propagation flags were reset properly on
    // the second call to initEvent.
    finishJSTest();
}, false);

target.dispatchEvent(e);

target.parentNode.removeChild(target);

</script>
</body>
</html>
